home *** CD-ROM | disk | FTP | other *** search
Wrap
Public Class ScrollableForm Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub Friend WithEvents chkAutoScroll As System.Windows.Forms.CheckBox Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents txtMarginWidth As System.Windows.Forms.TextBox Friend WithEvents txtMarginHeight As System.Windows.Forms.TextBox Friend WithEvents Label4 As System.Windows.Forms.Label Friend WithEvents GroupBox2 As System.Windows.Forms.GroupBox Friend WithEvents txtPositionY As System.Windows.Forms.TextBox Friend WithEvents Label2 As System.Windows.Forms.Label Friend WithEvents txtPositionX As System.Windows.Forms.TextBox Friend WithEvents Label3 As System.Windows.Forms.Label Friend WithEvents chkHScroll As System.Windows.Forms.CheckBox Friend WithEvents chkVScroll As System.Windows.Forms.CheckBox Friend WithEvents Label5 As System.Windows.Forms.Label Friend WithEvents ListBox1 As System.Windows.Forms.ListBox Friend WithEvents btnScrollControl As System.Windows.Forms.Button Friend WithEvents ListBox2 As System.Windows.Forms.ListBox Friend WithEvents Label6 As System.Windows.Forms.Label Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox 'Required by the Windows Form Designer Private components As System.ComponentModel.Container 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.Label3 = New System.Windows.Forms.Label() Me.Label1 = New System.Windows.Forms.Label() Me.txtPositionY = New System.Windows.Forms.TextBox() Me.txtPositionX = New System.Windows.Forms.TextBox() Me.chkAutoScroll = New System.Windows.Forms.CheckBox() Me.GroupBox1 = New System.Windows.Forms.GroupBox() Me.txtMarginHeight = New System.Windows.Forms.TextBox() Me.Label4 = New System.Windows.Forms.Label() Me.txtMarginWidth = New System.Windows.Forms.TextBox() Me.GroupBox2 = New System.Windows.Forms.GroupBox() Me.Label2 = New System.Windows.Forms.Label() Me.btnScrollControl = New System.Windows.Forms.Button() Me.chkVScroll = New System.Windows.Forms.CheckBox() Me.ListBox1 = New System.Windows.Forms.ListBox() Me.Label5 = New System.Windows.Forms.Label() Me.chkHScroll = New System.Windows.Forms.CheckBox() Me.ListBox2 = New System.Windows.Forms.ListBox() Me.Label6 = New System.Windows.Forms.Label() Me.ComboBox1 = New System.Windows.Forms.ComboBox() Me.GroupBox1.SuspendLayout() Me.GroupBox2.SuspendLayout() Me.SuspendLayout() ' 'Label3 ' Me.Label3.Location = New System.Drawing.Point(8, 32) Me.Label3.Name = "Label3" Me.Label3.Size = New System.Drawing.Size(40, 24) Me.Label3.TabIndex = 0 Me.Label3.Text = "X" Me.Label3.TextAlign = System.Drawing.ContentAlignment.TopRight ' 'Label1 ' Me.Label1.Location = New System.Drawing.Point(8, 32) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(48, 24) Me.Label1.TabIndex = 0 Me.Label1.Text = "Width" Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight ' 'txtPositionY ' Me.txtPositionY.Location = New System.Drawing.Point(176, 32) Me.txtPositionY.Name = "txtPositionY" Me.txtPositionY.Size = New System.Drawing.Size(48, 24) Me.txtPositionY.TabIndex = 1 Me.txtPositionY.Text = "" ' 'txtPositionX ' Me.txtPositionX.Location = New System.Drawing.Point(56, 32) Me.txtPositionX.Name = "txtPositionX" Me.txtPositionX.Size = New System.Drawing.Size(48, 24) Me.txtPositionX.TabIndex = 1 Me.txtPositionX.Text = "" ' 'chkAutoScroll ' Me.chkAutoScroll.Location = New System.Drawing.Point(24, 24) Me.chkAutoScroll.Name = "chkAutoScroll" Me.chkAutoScroll.Size = New System.Drawing.Size(152, 16) Me.chkAutoScroll.TabIndex = 0 Me.chkAutoScroll.Text = "AutoScroll" ' 'GroupBox1 ' Me.GroupBox1.Controls.AddRange(New System.Windows.Forms.Control() {Me.txtMarginHeight, Me.Label4, Me.txtMarginWidth, Me.Label1}) Me.GroupBox1.Location = New System.Drawing.Point(24, 56) Me.GroupBox1.Name = "GroupBox1" Me.GroupBox1.Size = New System.Drawing.Size(264, 64) Me.GroupBox1.TabIndex = 1 Me.GroupBox1.TabStop = False Me.GroupBox1.Text = "AutoScrollMargins property" ' 'txtMarginHeight ' Me.txtMarginHeight.Location = New System.Drawing.Point(176, 32) Me.txtMarginHeight.Name = "txtMarginHeight" Me.txtMarginHeight.Size = New System.Drawing.Size(48, 24) Me.txtMarginHeight.TabIndex = 1 Me.txtMarginHeight.Text = "" ' 'Label4 ' Me.Label4.Location = New System.Drawing.Point(120, 32) Me.Label4.Name = "Label4" Me.Label4.Size = New System.Drawing.Size(56, 24) Me.Label4.TabIndex = 0 Me.Label4.Text = "Height" Me.Label4.TextAlign = System.Drawing.ContentAlignment.MiddleRight ' 'txtMarginWidth ' Me.txtMarginWidth.Location = New System.Drawing.Point(56, 32) Me.txtMarginWidth.Name = "txtMarginWidth" Me.txtMarginWidth.Size = New System.Drawing.Size(48, 24) Me.txtMarginWidth.TabIndex = 1 Me.txtMarginWidth.Text = "" ' 'GroupBox2 ' Me.GroupBox2.Controls.AddRange(New System.Windows.Forms.Control() {Me.txtPositionY, Me.Label2, Me.txtPositionX, Me.Label3}) Me.GroupBox2.Location = New System.Drawing.Point(24, 136) Me.GroupBox2.Name = "GroupBox2" Me.GroupBox2.Size = New System.Drawing.Size(264, 64) Me.GroupBox2.TabIndex = 1 Me.GroupBox2.TabStop = False Me.GroupBox2.Text = "AutoScrollPosition property" ' 'Label2 ' Me.Label2.Location = New System.Drawing.Point(128, 32) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(40, 24) Me.Label2.TabIndex = 0 Me.Label2.Text = "Y" Me.Label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight ' 'btnScrollControl ' Me.btnScrollControl.Location = New System.Drawing.Point(24, 264) Me.btnScrollControl.Name = "btnScrollControl" Me.btnScrollControl.Size = New System.Drawing.Size(256, 40) Me.btnScrollControl.TabIndex = 3 Me.btnScrollControl.Text = "ScrollControlIntoView(ComboBox1)" ' 'chkVScroll ' Me.chkVScroll.Location = New System.Drawing.Point(168, 216) Me.chkVScroll.Name = "chkVScroll" Me.chkVScroll.Size = New System.Drawing.Size(112, 24) Me.chkVScroll.TabIndex = 2 Me.chkVScroll.Text = "VScroll" ' 'ListBox1 ' Me.ListBox1.ItemHeight = 18 Me.ListBox1.Location = New System.Drawing.Point(312, 88) Me.ListBox1.Name = "ListBox1" Me.ListBox1.Size = New System.Drawing.Size(272, 112) Me.ListBox1.TabIndex = 5 ' 'Label5 ' Me.Label5.Location = New System.Drawing.Point(312, 64) Me.Label5.Name = "Label5" Me.Label5.Size = New System.Drawing.Size(176, 24) Me.Label5.TabIndex = 4 Me.Label5.Text = "two listboxes" ' 'chkHScroll ' Me.chkHScroll.Location = New System.Drawing.Point(24, 216) Me.chkHScroll.Name = "chkHScroll" Me.chkHScroll.Size = New System.Drawing.Size(112, 24) Me.chkHScroll.TabIndex = 2 Me.chkHScroll.Text = "HScroll" ' 'ListBox2 ' Me.ListBox2.ItemHeight = 18 Me.ListBox2.Location = New System.Drawing.Point(312, 232) Me.ListBox2.Name = "ListBox2" Me.ListBox2.Size = New System.Drawing.Size(264, 76) Me.ListBox2.TabIndex = 5 ' 'Label6 ' Me.Label6.Location = New System.Drawing.Point(312, 328) Me.Label6.Name = "Label6" Me.Label6.Size = New System.Drawing.Size(128, 24) Me.Label6.TabIndex = 4 Me.Label6.Text = "one combobox" ' 'ComboBox1 ' Me.ComboBox1.DropDownWidth = 120 Me.ComboBox1.Location = New System.Drawing.Point(456, 328) Me.ComboBox1.Name = "ComboBox1" Me.ComboBox1.Size = New System.Drawing.Size(120, 26) Me.ComboBox1.TabIndex = 6 Me.ComboBox1.Text = "ComboBox1" ' 'ScrollableForm ' Me.AutoScaleBaseSize = New System.Drawing.Size(7, 17) Me.ClientSize = New System.Drawing.Size(616, 389) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.ComboBox1, Me.Label6, Me.ListBox2, Me.ListBox1, Me.Label5, Me.btnScrollControl, Me.chkVScroll, Me.chkHScroll, Me.GroupBox2, Me.GroupBox1, Me.chkAutoScroll}) Me.Font = New System.Drawing.Font("Microsoft Sans Serif", 11!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Name = "ScrollableForm" Me.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Show Me.Text = "ScrollableForm" Me.GroupBox1.ResumeLayout(False) Me.GroupBox2.ResumeLayout(False) Me.ResumeLayout(False) End Sub #End Region Private Sub ScrollableForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load RefreshControlValues() End Sub Dim ignoreChanges As Boolean ' refresh contents of controls Sub RefreshControlValues() ' ignore changes for while the form is being loaded or painted ignoreChanges = True chkAutoScroll.Checked = Me.AutoScroll txtMarginWidth.Text = Me.AutoScrollMargin.Width.ToString txtMarginHeight.Text = Me.AutoScrollMargin.Height.ToString txtPositionX.Text = Me.AutoScrollPosition.X.ToString txtPositionY.Text = Me.AutoScrollPosition.Y.ToString chkHScroll.Checked = Me.HScroll chkVScroll.Checked = Me.VScroll ignoreChanges = False End Sub Private Sub ScrollableForm_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint RefreshControlValues() End Sub ' bring ComboBox1 into view Private Sub btnScrollControl_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnScrollControl.Click Me.ScrollControlIntoView(ComboBox1) End Sub Private Sub chkAutoScroll_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkAutoScroll.CheckedChanged If Not ignoreChanges Then Me.AutoScroll = chkAutoScroll.Checked End If End Sub Private Sub txtMargin_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtMarginWidth.TextChanged, txtMarginHeight.TextChanged If Not ignoreChanges Then On Error Resume Next Me.AutoScrollMargin = New Size(CInt(txtMarginWidth.Text), CInt(txtMarginHeight.Text)) End If End Sub Private Sub txtPosition_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtPositionX.TextChanged, txtPositionY.TextChanged If Not ignoreChanges Then On Error Resume Next Me.AutoScrollPosition = New Point(CInt(txtPositionX.Text), CInt(txtPositionY.Text)) End If End Sub Private Sub chkHScroll_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkHScroll.CheckedChanged If Not ignoreChanges Then Me.HScroll = chkHScroll.Checked End If End Sub Private Sub chkVScroll_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkVScroll.CheckedChanged If Not ignoreChanges Then Me.VScroll = chkVScroll.Checked End If End Sub End Class